import org.json4s._
import org.json4s.JsonDSL._
import org.json4s.jackson.JsonMethods._
import java.util.Date


object demo2 {

  def main(args: Array[String]) {
    case class Twitter(id: Long, text: String, publishedAt: Option[java.util.Date])

    var twitters = Twitter(1, "hello scala", Some(new Date())) ::
      Twitter(2, "I like scala tour", None) :: Nil

    var json = ("twitters"
      -> twitters.map(
      t => ("id" -> t.id)
        ~ ("text" -> t.text)
        ~ ("published_at" -> t.publishedAt.toString())))

     // println(render(json))
    println(pretty(render(json)))
  // println("---------------------------------")
    val j=twitters.map(t=>
      ("id" -> t.id)
        ~ Map("text" -> t.text,"text2" -> t.text)

    )
      //println(pretty(render(j)))


    case class Winner(id: Long, numbers: List[Int])
    case class  Toto(w:Winner,m:Map[String,Int])
      val p=Toto(Winner(22,List(1,2,3,4)),Map("feel"->23,"aa"->32))
     val json2=("winner"->("id"->p.w.id)
       ~ ("number"->p.w.numbers)
       ~ ("map" -> p.m)
       ~ ("map" -> p.m)
       ) ~ ("map" -> p.m)

    println(pretty(render(json2)))



  }



}
